//
//  LTAccountCancellationExplainVC.m
//  Learn
//
//  Created by zyl_macbookpro on 2024/4/1.
//  Copyright © 2024 迟建国. All rights reserved.
//

#import "LTAccountCancellationExplainVC.h"

@interface LTAccountCancellationExplainVC ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic ,strong)UITableView *tableView;

@property(nonatomic ,strong)UIView *tableHeaderView;

@property(nonatomic ,strong)UIButton *confirmButton;


@end

@implementation LTAccountCancellationExplainVC
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self renderNavBarWithBackgroundImage:[UIImage imageWithColor:LTClearColor] backgroundColor:LTClearColor shadowColor:nil textAttributeDic:@{NSForegroundColorAttributeName:rgba(0, 0, 0, 1),NSFontAttributeName:MFontWithSize(17)} enableScrollEdgeAppearance:YES];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"撤销同意声明";
    // Do any additional setup after loading the view.
    [self setBackButtonIsHidden:NO];
    [self.view addSubview:self.tableView];
    [self.tableView reloadData];
    self.confirmButton.y = self.tableView.y + self.tableView.height;
    
}

- (void)confirmButtonAction
{
    [self.navigationController popToRootViewControllerAnimated:YES];
}
#pragma mark -UITableViewDelegate,UITableViewDelegate
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = nil;
    
    if (!cell)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@""];
        cell.selectionStyle =UITableViewCellSelectionStyleNone;
    }
    
    return cell;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 0;
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return 55;
    
}


#pragma mark -getters and setters
-(UITableView *)tableView{
    if (!_tableView){
        _tableView =[[UITableView alloc] initWithFrame:CGRectMake(0, LTTopBarHeight, LTScreenWidth, LTScreenHeight - LTTopBarHeight - LTBottomDangerousAreaHeight - 10 - 44) style:UITableViewStylePlain];
        [_tableView setDelegate:self];
        [_tableView setDataSource:self];
        _tableView.bounces = NO;
        [_tableView setBackgroundColor:LTClearColor];
        [_tableView setSeparatorColor:LTSeparatorColor];
        [_tableView setSeparatorInset:UIEdgeInsetsMake(0, 20, 0, 20)];
        
        [_tableView setTableHeaderView:self.tableHeaderView];
    }
    
    return _tableView;
}

-(UIButton *)confirmButton
{
    if (!_confirmButton)
    {
        _confirmButton = [UIButton new];
        _confirmButton.frame =CGRectMake(32, 40, LTScreenWidth - 64, 44);
        
        [_confirmButton setTitle:@"撤销同意保护" forState:UIControlStateNormal];
        // [_confirmButton setTitleColor:rgba(181, 181, 181, 1) forState:UIControlStateNormal];
        [_confirmButton setTitleColor:LTWhiteColor forState:UIControlStateNormal];
        [_confirmButton.titleLabel setFont:MFontWithSize(14)];
        [_confirmButton addTarget:self action:@selector(confirmButtonAction) forControlEvents:UIControlEventTouchUpInside];
        _confirmButton.backgroundColor = rgba(41, 121, 255, 1);
        _confirmButton.layer.cornerRadius = 22;
        _confirmButton.layer.shadowColor = rgba(41, 121, 255, 0.50).CGColor;
        _confirmButton.layer.shadowOffset = CGSizeMake(0,4);
        _confirmButton.layer.shadowOpacity = 1;
        _confirmButton.layer.shadowRadius = 6;
        [self.view addSubview:_confirmButton];
    }
    
    return _confirmButton;
}
-(UIView *)tableHeaderView
{
    if (!_tableHeaderView)
    {
        _tableHeaderView =[[UIView alloc] initWithFrame:CGRectMake(0, 0, LTScreenWidth, 250)];
        
        _tableHeaderView.backgroundColor = LTClearColor;
        UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(16, 12, LTScreenWidth - 32, 128)];
        bgView.backgroundColor = LTWhiteColor;
        [bgView setAllCornersWithCornerRadius:12];
        bgView.layer.cornerRadius = 12;
        bgView.layer.shadowColor = [UIColor colorWithRed:0/255.0 green:50/255.0 blue:83/255.0 alpha:0.0500].CGColor;
        bgView.layer.shadowOffset = CGSizeMake(0,2);
        bgView.layer.shadowOpacity = 1;
        bgView.layer.shadowRadius = 12;
        
        
        UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(32,24, LTScreenWidth - 64, 22)];
        titleLabel.font = MFontWithSize(16);
        titleLabel.text = @"撤销同意声明";
        [titleLabel setTextAlignment:NSTextAlignmentCenter];
        titleLabel.textColor = LTTextBlack;
        [_tableHeaderView addSubview:titleLabel];
        
        NSString *str = @"尊敬的用户，请您认真阅读并充分了解相关政策，政策涉及下述内容：您可以根据以下目录阅读对应章节，进一步了解本政策的具体内容：\n一、定义与解释\n二、我们如何收集和使用您的个人信息\n三、我们如何使用Cookie\n四、我们如何共享、转让、公开披露您的个人信息\n五、我们如何保护您的个人信息\n六、我们如何存储您的个人信息\n七、您如何实现管理您个人信息的权利\n八、我们如何保护未成年人的个人信息\n九、我们如何更新本政策\n十、如何联系我们\n十一、其他\n您已经同意《教师使用协议》、《教师隐私政策》和《儿童隐私保护政策》，我们依法尽全力保护您的个人信息。";
        NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
        style.lineSpacing = 5;
        NSMutableAttributedString *att = [[NSMutableAttributedString alloc] initWithString:str];
        [att addAttributes:@{NSParagraphStyleAttributeName:style} range:NSMakeRange(0, str.length)];
        UILabel *label = [[UILabel alloc] init];
        label.frame = CGRectMake(20,titleLabel.bottom  + 15,bgView.width - 40,CGFLOAT_MIN);
        label.numberOfLines = 0;
        [bgView addSubview:label];
        label.textColor = rgba(51, 51, 51, 1);
        label.font = RFontWithSize(13);
        label.attributedText = att;
        label.textAlignment = NSTextAlignmentLeft;
        [label sizeToFit];
        //label.width = bgView.width - 40;
        [bgView addSubview:label];
        [bgView addSubview:titleLabel];
        bgView.height = label.bottom+ 24;
        _tableHeaderView.height = bgView.bottom ;
        [_tableHeaderView addSubview:bgView];
        
    }
    
    return _tableHeaderView;
    
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end

